package plugs

import (
	"fmt"

	"gitee.com/wu-jin-feng/kinfu/fgin"
	"github.com/gin-gonic/gin"
)

func init() {
	// 将组件注册进入
	fgin.RegisteHttpPlug("my_mysql", &MyMysql{})
}

type MyMysql struct {
	Host string `yaml:"host" json:"host"`
	Port int    `yaml:"port" json:"port"`
}

func (c *MyMysql) Start(r *gin.Engine, logger *fgin.FginSugaredLogger) {
	MysqlInfo("Start MyMysql", c)
}

var Logger *fgin.FginSugaredLogger

func MysqlRegisteFginLog(l *fgin.FginSugaredLogger) {
	Logger = l
}

func MysqlInfo(info ...any) {
	if Logger == nil {
		fmt.Println(info...)
		return
	}
	Logger.Info(info...)
}
